package com.fingerth.crawler.room;

import android.text.TextUtils;

import androidx.room.Entity;
import androidx.room.PrimaryKey;

import com.fingerth.crawler.bean.NovelListBean;

@Entity
public class NovelCollection {
    @PrimaryKey(autoGenerate = true)
    public Long id;

    public String fictionId;
    public String title;
    public String cover;
    public String author;
    public String descs;
    public String fictionType;
    public String creationTime;
    public String updateTime;

    public NovelCollection() {

    }

    public NovelCollection(NovelListBean.NovelItemBean bean) {
        this.fictionId = bean.fictionId;
        this.title = bean.title;
        this.cover = bean.cover;
        this.author = bean.author;
        this.descs = bean.descs;
        this.fictionType = bean.fictionType;
        this.creationTime = bean.creationTime;
        this.updateTime = bean.updateTime;
    }

    public boolean change(NovelListBean.NovelItemBean bean) {
        boolean isChange = false;
        if (!TextUtils.equals(this.fictionId, bean.fictionId)) {
            this.fictionId = bean.fictionId;
        }
        if (!TextUtils.equals(this.title, bean.title)) {
            this.title = bean.title;
            isChange = true;
        }
        if (!TextUtils.equals(this.cover, bean.cover)) {
            this.cover = bean.cover;
            isChange = true;
        }
        if (!TextUtils.equals(this.author, bean.author)) {
            this.author = bean.author;
            isChange = true;
        }
        if (!TextUtils.equals(this.descs, bean.descs)) {
            this.descs = bean.descs;
            isChange = true;
        }
        if (!TextUtils.equals(this.fictionType, bean.fictionType)) {
            this.fictionType = bean.fictionType;
            isChange = true;
        }
        if (!TextUtils.equals(this.creationTime, bean.creationTime)) {
            this.creationTime = bean.creationTime;
            isChange = true;
        }
        if (!TextUtils.equals(this.updateTime, bean.updateTime)) {
            this.updateTime = bean.updateTime;
            isChange = true;
        }
        return isChange;
    }
}
